import { queryAllCategory } from "@/api/content/category";
import { Category } from "@/types/content/category";
import { useCallback, useEffect, useState } from "react";


export const useCategoryList = () => {
  const [categoryList,setCategoryList] = useState<Array<Category.Row>>([]);
  /**
   * 获取分类列表
   */
  const getCategoryList = useCallback(async () => {
    const res = await queryAllCategory();
    if (res.code === 200) {
      setCategoryList(res.data || []);
    }
  },[])
  useEffect(() => {
    getCategoryList();
  },[getCategoryList]);
  return {
    categoryList,
  };
};
